#include <iostream>
using namespace std;
typedef struct Tnode
{
    int data;
    struct Tnode* left;
    struct Tnode* right;
    Tnode(int x)
    {
        this->data=x;
        this->left=NULL;
        this->right=NULL;
    }
    Tnode()
    {

    }
}Node;
//递归建树
void createTree(Tnode* &root)
{
    int x;
    cin>>x;
    if(x==-1)
        root=NULL;
    else
    {
        root=new Tnode(x);
        createTree(root->left);
        createTree(root->right);
    }
}
void preorder(Tnode* root)
{
    if(root)
    {
        cout<<root->data<<" ";
        preorder(root->left);
        preorder(root->right);
    }
}
//统计叶子节点的个数
void countLeave(Tnode* root,int& cnt)
{
   if(root)
   {
       if(!root->left&&!root->right)
       {
           cnt++;
       } else
       {
           countLeave(root->left,cnt);
           countLeave(root->right,cnt);
       }
   }
}


//求二叉树的深度
int getDepth(Tnode* root)
{
    if(root)
    {
        return max(getDepth(root->left),getDepth(root->right))+1;
    } else
    {
        return 0;
    }
}
int main() {
    Tnode* root=NULL;
    createTree(root);
    preorder(root);
    int cnt=0;
    countLeave(root,cnt);
    cout<<"叶子结点个数为"<<cnt;
    int depth=getDepth(root);
    cout<<"二叉树的深度为"<<depth;
    return 0;
}
